package com.tianming.wy.cmn.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.tianming.wy.cmn.service.MenuService;
import com.tianming.wy.common.result.Result;
import com.tianming.wy.model.cmn.Menu;
import com.tianming.wy.vo.cmn.MenuEeVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @author yonkig
 */
// @CrossOrigin //跨域
@Api(tags = "菜单管理")
@RestController
@RequestMapping(value = "/admin/cmn/menu")
public class MenuController {

    @Autowired
    private MenuService menuService;

    @ApiOperation(value = "用户根据权限获取可用菜单列表")
    @GetMapping(value = "/getUserMenus")
    public Result<List<Menu>> getUserMenus() {
        List<Menu> list = menuService.getUserMenus();
        return Result.ok(list);
    }
    @ApiOperation(value = "分页查询菜单")
    @PostMapping(value = "/queryMenus")
    public Result queryMenus(@RequestBody MenuEeVo menuEeVo) {
        IPage<Menu> pageModel = menuService.queryMenus(menuEeVo);
        return Result.ok(pageModel);
    }
    @ApiOperation(value = "用户根据权限获取可用菜单列表")
    @PostMapping(value = "/saveBatch")
    public Result<List<Menu>> saveBatch(@RequestBody List<Menu> list) {
        menuService.saveBatch(list);
        return Result.ok();
    }
}
